<?php get_instance()->view('common/header');?>
<style type="text/css">
h3, .h3 {
    font-size: 16px;
}
.form-section {
    margin: 15px 0px 15px 0px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}
.form-group {
    margin-bottom: 10px;
}
</style>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
		<div class="page-content">
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->
					<h3 class="page-title">订单详情</h3>
					<ul class="page-breadcrumb breadcrumb">
						<li class="btn-group"><a class="btn default ml_5 return"
							href="<?php echo getUrl('deliveryman/order');?>"><i
								class="fa fa-chevron-left"></i> 返回</a></li>
						<li><i class="fa fa-home"></i> <a
							href="<?php echo getUrl('home');?>"> 首页 <i
								class="fa fa-angle-right"></i>
						</a></li>
						<li><a href="<?php echo getUrl('deliveryman/order');?>">运单管理 <i
								class="fa fa-angle-right"></i></a></li>
						<li><a href="javascript:void(0);">运单详情</a></li>
					</ul>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
			</div>
			<div class="row">
				<div class="col-lg-4 col-md-3 col-sm-6 col-xs-12">
					<div class="dashboard-stat blue">
						<div class="visual">
							<i class="fa fa-clock-o"></i>
						</div>
						<div class="details">
							<div class="number">
								<?php 
								$tI = ceil((($status == 4 ? strtotime($complete_time) : time()) - 
										($status == 1 ? $rob_expect_time : strtotime($expect_arrive_time))) / 60);
								$show  = '';
								if(abs($tI) < 60){
									$show = abs($tI).'分钟';
								}elseif(abs($tI) > 60){
									$e = abs($tI) % 60;
									$show = floor(abs($tI) / 60).'小时';
									if($e > 0){
										$show .= $e.'分钟';
									}
								}
								
								if($tI > 0){
									if($status == 4){
										$show = '超时'.$show;
									}else{
										$show = '已超时'.$show;
									}
								}else{
									if($status == 4){
										$show = '提前'.$show.'送达';
									}else{
										$show = $show.'后超时';
									}
								}
									echo $status == 5 ? '订单已取消' : $show;
								?>
							</div>
							<div class="desc">
								 超时状态
							</div>
						</div>
					</div>
				</div>
				<div class="col-lg-4 col-md-3 col-sm-6 col-xs-12">
					<div class="dashboard-stat green">
						<div class="visual">
							<i class="fa fa-cny"></i>
						</div>
						<div class="details">
							<div class="number">
								 <?php echo $income;?>
							</div>
							<div class="desc">
								 配送费
							</div>
						</div>
					</div>
				</div>
				<div class="col-lg-4 col-md-3 col-sm-6 col-xs-12">
					<div class="dashboard-stat purple">
						<div class="visual">
							<i class="fa fa-adjust"></i>
						</div>
						<div class="details">
							<div class="number">
								<?php echo $statusStr;?>
							</div>
							<div class="desc">
								 状态
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-12">
				 <div class="row">
						<div class="col-md-8">
						<div class="portlet box white">
						<div class="portlet-title">
							<div class="caption">
								订单详情
							</div>
						</div>
						<div class="portlet-body form">
						
						<form class="form-horizontal" role="form" style="margin-top:20px;">
							<div class="form-body">
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">编号：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo $code;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">配送距离：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $distance > 1000 ? round($distance / 1000, 2).'km' : $distance.'m';?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">下单时间：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo $addtime;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
									<?php if($status > 1 && $status < 5):?>
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">取货时间：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo $pickup_time;?>
												</p>
											</div>
										</div>
									</div>
									<?php endif;?>
									<!--/span-->
									<?php if($status == 4):?>
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">完成时间：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo $complete_time;?>
												</p>
											</div>
										</div>
									</div>
									<?php endif;?>
								</div>
								<div class="row">
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">区域：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo $area;?>
												</p>
											</div>
										</div>
									</div>
								</div>
								<div class="row">
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">配送商品：</label>
											<div class="col-md-9">
												<?php foreach ($product as $v):?>
												<p class="form-control-static">
													<?php echo $v['name'];?> （<?php echo $v['quantity'];?>）
												</p>
												<?php endforeach;?>
											</div>
										</div>
									</div>
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">备注：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo $remark;?>
												</p>
											</div>
										</div>
									</div>
								</div>
								<?php if($ap):?>
								<h3 class="form-section">异常报备</h3>
								<div class="row">
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">原因：</label>
											<div class="col-md-9">
											  <p class="form-control-static">
												<?php echo $ap['type'];?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">备注：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo nl2br($ap['content']);?>
												</p>
											</div>
										</div>
									</div>
								</div>
								<?php endif;?>
								<h3 class="form-section">店铺信息</h3>
								<!--/row-->
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">店铺：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $send_user;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">联系电话：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $send_mobile;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
								</div>
								<!--/row-->
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">地址：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $send_address;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
								</div>
								<!--/row-->
								<h3 class="form-section">下单人信息</h3>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">姓名：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													<?php echo $send_to_user;?>
												</p>
											</div>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">联系电话：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $send_to_mobile;?>
												</p>
											</div>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">配送地址：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $send_to_address;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
								</div>
								<!--/row-->
								<?php if($deliveryman):?>
								<h3 class="form-section">配送员</h3>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">姓名：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $deliveryman;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">联系电话：</label>
											<div class="col-md-9">
												<p class="form-control-static">
													 <?php echo $deliveryman_mobile;?>
												</p>
											</div>
										</div>
									</div>
									<!--/span-->
								</div>
								<?php endif;?>
								</div>
							</form>
						</div>
					</div>
						</div>
						<div class="col-md-4">
						<div class="portlet box white">
						<div class="portlet-title">
							<div class="caption">
								位置
							</div>
						</div>
						<div class="portlet-body">
							<div id="map" style="width:100%;height:505px;"></div>
							<script type="text/javascript">
							var map = null;
							$(function(){
								var pt = new BMap.Point(<?php echo $longitude;?>, <?php echo $latitude;?>);
								map = new BMap.Map("map");           
								map.centerAndZoom(pt, 15);
								map.enableScrollWheelZoom(true);
								var myIcon = new BMap.Icon("<?php echo base_url('static/img/order.png');?>", new BMap.Size(50,50));
								var marker2 = new BMap.Marker(pt, {icon:myIcon});  // 创建标注
								map.addOverlay(marker2);

								var pt = new BMap.Point(<?php echo $send_to_longitude;?>, <?php echo $send_to_latitude;?>);
								var myIcon = new BMap.Icon("<?php echo base_url('static/img/order.png');?>", new BMap.Size(50,50));
								var marker2 = new BMap.Marker(pt, {icon:myIcon});  // 创建标注
								map.addOverlay(marker2);

								<?php if($status > 1 && $status < 4):?>
									var pt = new BMap.Point(<?php echo $deliveryman_longitude;?>, <?php echo $deliveryman_latitude;?>);
									var myIcon = new BMap.Icon("<?php echo base_url('static/img/courier.png');?>", new BMap.Size(50,50));
									var marker2 = new BMap.Marker(pt, {icon:myIcon});  // 创建标注
									map.addOverlay(marker2);
								<?php endif;?>
							});
							</script>
						</div>
					</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<?php echo $ak;?>"></script>
</body>
</html>